﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Xejen.Communication.Soap
{
    /// <summary>
    /// 表示服务请求结果
    /// <para>
    /// 使用<see langword="object"/>类型作为返回的数据结果类型
    /// </para>
    /// </summary>
    /// <creator>marc</creator>
    public class SoapResponse : Result<object>
    {
        /// <inheritdoc cref="SoapResponse"/>
        public SoapResponse()
        {

        }

        /// <summary>
        /// 返回一个表示成功的<see cref="SoapResponse"/>对象
        /// </summary>
        /// <param name="returnData"><inheritdoc cref="Result{T}.ReturnData" path="/summary"/></param>
        public static SoapResponse Success(object returnData)
        {
            SoapResponse response = new SoapResponse();
            response.ReturnData = returnData;
            response.Code = SuccessCode;

            return response;
        }

        /// <summary>
        /// 返回一个表示失败的<see cref="SoapResponse"/>对象
        /// </summary>
        /// <param name="code"><inheritdoc cref="IResult.Code" path="/summary"/></param>
        /// <param name="exception"><inheritdoc cref="IResult.Exception" path="/summary"/></param>
        public static SoapResponse Fail(int code, Exception exception = default)
        {
            return new SoapResponse()
            {
                Code = code,
                Exception = exception,
            };
        }
    }
}
